import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TerOrderDayVo, TerUserDayVo, TerUserStartAndEndBo, TerGroupBuyBo, TerGroupBuyTotalVo, ApiResponse,TerOrderStatsBo } from '@/api/tearoom/queryCount/types';
import { AccountsForm } from '@/api/tearoom/accounts/types';
/**
 * 获取用户数量信息
 *
 * @param daynum 天数，用于查询指定天数前的用户数量信息
 * @returns 返回一个AxiosPromise对象，解析后得到TerUserDayVo类型的用户数量信息
 */
export const getUserCountInfo = (query?: TerUserStartAndEndBo): AxiosPromise<TerUserDayVo> => {
  return request({
    url: '/tearoom/teruser/queryUserCount',
    method: 'get',
    params: query
  });
};

/**
 * 获取订单统计信息
 *
 * @param daynum 查询的天数
 * @returns 返回AxiosPromise对象，包含TerOrderDayVo类型的数据
 */
export const getOrderCountInfo = (query?: TerUserStartAndEndBo): AxiosPromise<TerOrderDayVo> => {
  // 发送HTTP请求
  return request({
    url: '/tearoom/order/queryOrderCount',
    method: 'get',
    params: query
  });
};
export const getRefundInfo = (query?: TerUserStartAndEndBo): AxiosPromise<TerOrderDayVo> => {
  // 发送HTTP请求
  return request({
    url: '/tearoom/order/queryRefund',
    method: 'get',
    params: query
  });
};
/**
 * 获取团购统计信息
 *
 * @returns TerGroupBuyTotalVo
 */
export const getGroupBuyTotal = (query?: TerGroupBuyBo): AxiosPromise<TerGroupBuyTotalVo> => {
  // 发送HTTP请求
  return request({
    url: '/tearoom/groupBuy/total',
    method: 'post',
    data: query
  });
};
export const getRoomTotal = (): AxiosPromise<ApiResponse<number>> => {
  // 发送HTTP请求
  return request({
    url: '/tearoom/roomDetails/queryTotal',
    method: 'get'
  });
};

export const getBalances = (query?: AccountsForm): AxiosPromise<ApiResponse<number>> => {
  return request({
    url: '/tearoom/accounts/queryBalance',
    method: 'get',
    params: query
  });
};

/**
 * 获取订单统计信息
 *
 * @returns TerOrderStatsBo
 */
export const getOrderTotalStats = (query?: TerOrderStatsBo): AxiosPromise<TerOrderStatsBo> => {
  // 发送HTTP请求
  // 发送HTTP GET请求到指定的URL
  return request({
    // 请求的URL
    url: '/tearoom/order/stats',
    // 请求的方法，这里使用GET方法
    method: 'get',
    // 请求的参数，从函数参数query中获取
    params: query
  });
};

export const getBalancePay = (query?: TerUserStartAndEndBo): AxiosPromise<TerOrderDayVo> => {
  // 发送HTTP请求
  return request({
    url: '/tearoom/order/queryBanlcPay',
    method: 'get',
    params: query
  });
};